window.Notify={
	enabled:false,
	__container:null,
	__content:null,
	__button:null,
	__prompt:null,
	__hidden:true,
	__setup:function(){try{
		if(this.__setupDone || !this.enabled)
			return;
			
		this.__container=document.createElement("div");
		this.__container.id="console-container";
		
		this.__content=document.createElement("div");
		this.__content.style.position="absolute";
		this.__content.style.top="0px";
		this.__content.style.left="0px";
		this.__content.style.width="100%";
		this.__content.style.height="-moz-calc( 100% - 58px )";
		this.__content.style.overflow="auto";
		this.__content.style.padding="0px";
		this.__content.style.margin="0px";
		this.__container.appendChild(this.__content);
		
		this.__prompt=document.createElement("input");
		this.__prompt.style.position="absolute";
		this.__prompt.style.display="block";
		this.__prompt.style.bottom="29px";
		this.__prompt.style.padding="1px";
		this.__prompt.style.left="0px";
		this.__prompt.style.width="100%";
		this.__prompt.style.height="29px";
		this.__prompt.style.overflow="hidden";
		this.__prompt.style.padding="0px";
		this.__prompt.style.margin="0px";
		this.__prompt.onkeypress=function(evt){
			if(evt.keyCode!=13)
				return;
				
			
			var v=eval(this.value);
			if(typeof(v)!="undefined")
				Notify.echo("Eval: "+this.value+" ; returned: "+v.toString());
			else
				Notify.echo("Eval: "+this.value+" ; returned nothing.");
				
			this.value="";
		};
		
		this.__container.appendChild(this.__prompt);
		
		this.__button=document.createElement("div");
		this.__button.style.position="absolute";
		this.__button.style.bottom="0px";
		this.__button.style.left="0px";
		this.__button.style.width="100%";
		this.__button.style.height="24px";
		this.__button.style.overflow="hidden";
		this.__button.style.padding="0px";
		this.__button.style.paddingLeft="8px";
		this.__button.style.paddingRight="8px";
		this.__button.style.margin="0px";
		this.__button.style.color="#fff";
		this.__button.style.fontWeight="bold";
		this.__button.style.textAlign="center";
		this.__button.style.paddingTop="3px";
		this.__button.style.textShadow="0px 0px 5px black";
		this.__button.style.borderTop="1px solid #555";
		this.__button.style.borderBottom="1px solid #555";
		this.__button.style.borderBottomLeftRadius="3px";
		this.__button.style.borderBottomRightRadius="3px";
		this.__button.style.background="-moz-linear-gradient(#eee, #ccc, #bbb)";
		
		this.__button.onclick=this.show.bind(this);
		this.__button.style.cursor="pointer";
		this.__container.appendChild(this.__button);
		this.__button.appendChild(document.createTextNode("Developer Console"));
		
		if(document.body && document.querySelector("#console")){
			document.querySelector("#console").appendChild(this.__container);
		}else{
			window.addEventListener("load",(function(){
				document.querySelector("#console").appendChild(this.__container);
			}).bind(this),false);
		}
		
		this.__setupDone=true;
		
		this.show();
	}catch(e){trace(e);}},
	__setupDone:false,
	
	hide:function(){try{
		this.__setup();
		
		if(this.__hidden)
			return;
		
		this.__hidden=true;
		this.__container.className="";
		this.__button.onclick=this.show.bind(this);
	}catch(e){trace(e);}},
	show:function(){try{
		this.__setup();
		
		if(!this.__hidden)
			return;
		
		this.__hidden=false;
		this.__container.className="expanded";
		this.__button.onclick=this.hide.bind(this);
	}catch(e){trace(e);}},
	
	echo:function(msg,prio){try{
		this.__setup();
		if(!prio)
			prio=0;
				
		var text=document.createElement("div");
		text.style.padding="5px";
		text.style.clear="both";
		text.style.background=[
			"-moz-linear-gradient(#d5e9ff, #fff)",
			"-moz-linear-gradient(#fff0d0, #fff)",
			"-moz-linear-gradient(#ffd8d0, #fff)"
		][prio];
		text.style.borderBottom="1px solid #ddd";
		
		var date=document.createElement("span");
		date.style.fontWeight="bold";
		date.appendChild(document.createTextNode((new Date()).toLocaleTimeString()+": "));
		
		text.appendChild(date);
		msg=typeof(msg)=="string" || typeof(msg)=="number"?document.createTextNode(msg):msg;
		var msgC=document.createElement("span");
		msgC.appendChild(msg);
		msgC.setAttribute("class","notify-message");
		text.appendChild(msgC);
		
		
		if(!this.__content.firstChild)
			this.__content.appendChild(text);
		else
			this.__content.insertBefore(text,this.__content.firstChild);
		
		
		
		return text;
	}catch(e){trace(e);}},
	
	prompt:function(msg,actions,prio){try{
		if(arguments.length<3)
			prio=2;
			
		var node=this.echo(msg,prio);
		
		var buttonContainer=document.createElement("div");
		buttonContainer.setAttribute("style","text-align:right;");
		for(var i in actions){
			var button=document.createElement("input");
			button.type="button";
			button.setAttribute("style","margin-left:10px;");
			button.onclick=function(){
				var r=this.action();

				if(!r){
					this.button.blur();
					this.button.disabled=true;
					for(var j=0;j<this.buttons.childNodes.length;j++){
						this.buttons.childNodes[j].onmousedown=function(evt){evt.preventDefault();};
						this.buttons.childNodes[j].onclick=function(evt){evt.preventDefault();};
						if(this.buttons.childNodes[j]!=this.button)
							this.buttons.removeChild(this.buttons.childNodes[j]);
					}
				}
			}.bind({"action":actions[i],"buttons":buttonContainer,"value":i,"button":button});
			button.value=i;
			buttonContainer.appendChild(button);
		}
		node.appendChild(buttonContainer);
	}catch(e){trace(e);}},
	
	
};